<template>
  <div class="add">
    <van-nav-bar title="地址新增" left-text="返回" left-arrow @click-left="onClickLeft" fixed />
    <div class="list">
      <van-form @submit="onSubmit">
        <van-field v-model="contacts" label="联系人" placeholder="联系人" />

        <van-field v-model="contactsPhone" label="电话" placeholder="联系人电话" />

        <van-field v-model="address" label="详细地址" placeholder="联系人详细地址" />

        <van-radio-group v-model="isDefault" direction="horizontal" class="dan">
          <van-radio name="0">默认地址</van-radio>
          <van-radio name="1">非默认地址</van-radio>
        </van-radio-group>
        <div style="margin: 16px;">
          <van-button round block type="info" native-type="submit">提交</van-button>
        </div>
      </van-form>
    </div>
  </div>
</template>
<script>
import areaList from "../assets/area.js";

export default {
  data() {
    return {
      contacts: "",
      contactsPhone: "",
      address: "",
      isDefault: "0"
    };
  },
  methods: {
    onSubmit() {
      let paramForm = {
        contacts: this.contacts,
        contactsPhone: this.contactsPhone,
        address: this.address,
        isDefault: this.isDefault
      };
      this.$axios.post("prod-api/app/address/create", paramForm).then(res => {
        if (200 == res.data.code) {
          this.$router.go(-1);
          this.$toast.fail(res.data.msg);
        } else {
          this.$toast.fail(res.data.msg);
        }
      });
    },
    onClickLeft() {
      this.$router.go(-1);
    }
  },
  mounted() {}
};
</script>
<style lang="scss" scoped>
.van-nav-bar {
  background: url("../assets/bg2.png");
}
.dan {
  margin-top: 15px;
  margin-left: 20%;
  margin-bottom: 65px;
}
.van-button__text {
  background-color: dodgerblue;
  border: 0;
}
.list {
  margin-top: 50px;
}
.van-button::before {
  background-color: blue;
}
</style>